import CodeBlock from "@theme/CodeBlock";

import Expect from "!!raw-loader!./03.expect.zig";
import IfExpression from "!!raw-loader!./03.if-expression.zig";

# If Expressions

Zig's if statements accept `bool` values (i.e. `true` or `false`). Unlike languages
like C or Javascript, there are no values that implicitly coerce to bool values.

Here, we will introduce testing. Save the below code and compile + run it with
`zig test file-name.zig`. We will be using the
[`expect`](https://ziglang.org/documentation/master/std/#std;testing.expect)
function from the standard library, which will cause the test to fail if it's
given the value `false`. When a test fails, the error and stack trace will be
shown.

<CodeBlock language="zig">{Expect}</CodeBlock>

If statements also work as expressions.

<CodeBlock language="zig">{IfExpression}</CodeBlock>
